#include<bits/stdc++.h>
#define y1 Y1
#define fi first
#define endl "\n"
#define se second
#define PI acos(-1)
#define int long long
#define pb(x) push_back(x)
#define PII pair<int, int>
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define _for(i, a, b) for(int i = a; i <= b; ++i)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;

const int N = 2e5 + 10;
const int mod = 1e9 + 7;

int a[N];
int n, m, t, ret;
string s;

bool check(int x) {
	int p = 0;
	int pp = x;
	
	while(x) {
		p += x % 10;
		x /= 10;
	}	
//	cout << "x = " << pp << "p = " << p << endl; 
	if(p % 2)return false;
	return p < pp && a[p];
}

signed main() {
	IOS;
	a[2] = 1;
	a[4] = 1;
	a[6] = 1;
	a[8] = 1; 
	cin >> n;
	for(int i = 1; i <= n; i ++ ) {
		if(a[i] == 1) {
			ret ++ ;
		} else {
			if(check(i)) {
				a[i] = 1;
				ret ++ ;
			}
		}
	}
//	cout << "a[11] = " << a[11] << endl;
	cout << ret << endl;
	return 0;
}


